package com.authority.framework.web.service.impl;

import com.authority.framework.base.service.impl.BaseServiceImpl;
import com.authority.framework.base.entity.DTreeEntity;
import com.authority.framework.web.domain.SysDeptEntity;
import com.authority.framework.web.service.SysDeptService;
import org.beetl.sql.core.SQLManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: authority
 * @description: 菜单 impl层
 * @author: Mr.Yan
 * @create: 2018-11-15 13:47
 **/
@Service
@Transactional
public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptEntity> implements SysDeptService {

	@Autowired
	private SQLManager sqlManager;

	//  参数
	private Map<String, String> paramMap = null;

	/**
	 * @Description:获取部门树数据
	 * @Param:
	 * @return:
	 * @Author: Mr.Yan
	 * @Date: 2018/12/14
	 */

	@Override
	public List<DTreeEntity> findDTreeData() {
		paramMap = new HashMap<>();
		return sqlManager.select("system/SysDeptSql.findDTreeData", DTreeEntity.class, paramMap);
	}

	/**
	 * 获取角色和部门表关联数据
	 * @param roleId
	 * @return
	 */
	@Override
	public List<SysDeptEntity> findListByRoleId(String roleId) {
		paramMap = new HashMap<>();
		paramMap.put("roleId",roleId);
		return sqlManager.select("system/SysDeptSql.findListByRoleId",SysDeptEntity.class,paramMap);
	}

	/**
	 * 获取部门树数据展示
	 * @param ajaxMap
	 * @return
	 */
	@Override
	public List<SysDeptEntity> findMenuList(Map<String, Object> ajaxMap) {
		return sqlManager.select("system/SysDeptSql.pageInfo",SysDeptEntity.class,ajaxMap);
	}
}
